package com.subdemo.wordmachine.controller;


import com.subdemo.wordmachine.common.AjaxResult;
import com.subdemo.wordmachine.domain.Word;
import com.subdemo.wordmachine.service.WordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping("/word")

public class WordController {
    @Autowired
    private WordService service;


    /**
     * 获得单词
     * @param id
     * @return
     */
    @GetMapping("/getEn")
    public AjaxResult getEn(@RequestParam Integer id) {
        String word = service.selectByIdGetEn(id);
        return AjaxResult.success(word);
    }

    /**
     * 获取三个选项
     */
    @GetMapping("/getChoose")
    public AjaxResult getChoose (@RequestParam Integer id) {
        List<Word> chooseData = service.getChooseData(id);
        return AjaxResult.success(chooseData);
    }
    /**
     * 获取单词数量
     * @return
     */
    @GetMapping("/getCount")
    public AjaxResult getCount() {
        Integer num = service.getWordCount();
        return AjaxResult.success(num);
    }

    /**
     * 用于判断答案是否正确
     */
    @GetMapping("/checkAnswer")
    public AjaxResult checkAnswer(@RequestParam Integer exactId,
                                  @RequestParam Integer chooseId) {
        Boolean flag = service.checkAnswer(exactId, chooseId);
        return AjaxResult.success(flag);
    }

    /**
     * 获取全部词性
     */




}
